package com.health.viewscontrols;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.ViewStub;
import android.widget.ListView;

import com.health.R;
import com.health.adapter.SatisfactionAdapter;
import com.health.fragment.jtys.JTYSHome;
import com.health.tablebean.JTYSDoctorEvaluateBean;

import java.util.ArrayList;
import java.util.List;

public class MYDActivity extends NovaActivity {

    private View satisfactionView = null;
    private ListView lv_satisfaction;
    List<JTYSDoctorEvaluateBean> list;
    SatisfactionAdapter adapter;
    JTYSHome home = null;
    private String myd;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.jtys_satisfaction);

        lv_satisfaction = (ListView) findViewById(R.id.lv_satisfaction);

        list = new ArrayList<>();
        View head = View.inflate(MYDActivity.this, R.layout.jkjy_satisfaction_list_head, null);
        lv_satisfaction.addHeaderView(head);
    }

    private void initViews(View view) {

    }

    @Override
    public void findViews() {

    }

    @Override
    public void setListeners() {

    }

    @Override
    protected void onResume() {
        super.onResume();
        refresh();
    }

    public void refresh() {
        if (home == null) {
            home = new JTYSHome();
        }
        myd = home.myd;
        if (myd.equals("3")) {
            list = NovaApplication.fdbmanger.findAllByWhere(JTYSDoctorEvaluateBean.class,
                    "creater='" + NovaApplication.getJgrno() + "'");
        } else {
            list = NovaApplication.fdbmanger.findAllByWhere(JTYSDoctorEvaluateBean.class,
                    "creater='" + NovaApplication.getJgrno() + "'" + "and satisfiedState ='" + myd + "'");
        }
        // list =
        // NovaApplication.fdbmanger.findAllByWhere(JTYSDoctorEvaluateBean.class,
        // "creater='" + NovaApplication.getJgrno() + "'");
        adapter = new SatisfactionAdapter(MYDActivity.this, list);

        lv_satisfaction.setAdapter(adapter);
        lv_satisfaction.addFooterView(new ViewStub(MYDActivity.this));
        adapter.notifyDataSetChanged();
        Log.e("tag", "SatisfactionFragment onResume " + list.size());
    }
}
